package com.caine.globaltransaction.aspect;

import com.caine.globaltransaction.connection.CaineConnection;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

import java.sql.Connection;

/**
 * @Author: CaineZhu
 * @Description:
 * @Date: Created in 12:53 2020/11/24
 * @Modified By:
 */
@Component
@Aspect
public class CaineDataSourceAspect {

    @Around("execution(* javax.sql.DataSource.getConnection(..))")
    public Connection around(ProceedingJoinPoint point) throws Throwable {
        Connection connection = (Connection) point.proceed();
        return new CaineConnection(connection);
    }
}
